/**
 * Created by shq1 on 2017/2/17.
 */
function solveDate(date) {
  var week = "周日";
  date = parseInt(date);
  switch(date) {
    case 2:
      week = "周一";
      break;
    case 3:
      week = "周二";
      break;
    case 4:
      week = "周三";
      break;
    case 5:
      week = "周四";
      break;
    case 6:
      week = "周五";
      break;
    case 7:
      week = "周六";
      break;
  }
  return week;
}
function toDecimal2(x) {
  var f = parseFloat(x);
  if (isNaN(f)) {
    return false;
  }
  var f = Math.round(x * 100) / 100;
  var s = f.toString();
  var rs = s.indexOf('.');
  if (rs < 0) {
    rs = s.length;
    s += '.';
  }
  while (s.length <= rs + 2) {
    s += '0';
  }
  return s;
}
//获取当前时间 yyyy-mm-dd
function getCurrentDate() {
  var myDate = new Date();
  //var year = myDate.getYear(); //获取当前年份(2位)
  var year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  var month = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  var day = myDate.getDate(); //获取当前日(1-31)
  var date = year + "-" + month + "-" + day;
  return date;
}
//获取当前日期
function getCurrentDay() {
  var myDate = new Date();
  var d = myDate.getDay();
  // var week = "周日";
  // switch(d) {
  //   case 1:
  //     week = "周一";
  //     break;
  //   case 2:
  //     week = "周二";
  //     break;
  //   case 3:
  //     week = "周三";
  //     break;
  //   case 4:
  //     week = "周四";
  //     break;
  //   case 5:
  //     week = "周五";
  //     break;
  //   case 6:
  //     week = "周六";
  //     break;
  // }
  return d+1;
}
module.exports = {
  solveDate:solveDate,
  toDecimal2:toDecimal2,
  getCurrentDate:getCurrentDate,
  getCurrentDay:getCurrentDay
}
